#include "main.h"

__IO uint32_t Tick=0;
extern __IO uint16_t Period;
void SysTick_Handler(void){
	Tick++;
}
void PORTC_PORTD_IRQHandler(void){
	while(SW1_GetFlagIRQ()){
		if(Period > 2000){
			Period =2000;
		}	
		else{	
			Period +=100;
		}
		SW1_ClearFlagIRQ();
	}
	while(SW2_GetFlagIRQ()){
		if(Period<100){
			Period = 100;
		}
		else{
			Period -= 100;	
		}			
		SW2_ClearFlagIRQ();		
	}
	PIT_ConfigValue(TIMER0, Period);
	PIT_EnableIRQ(TIMER0, MODE_NOCHAIN);
}
void PIT_IRQHandler(void){
	while(PIT_GetFlag(TIMER0)){
		Toggle_Red();
		Toggle_Green();
		PIT_ClearFlag(TIMER0);
	}
	while(PIT_GetFlag(TIMER1)){
		printf("\r\nPeriod of led: %d ms", Period);
		PIT_ClearFlag(TIMER1);
	}
}